<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="IE=edge" >
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
    <title>Aliplayer Functions</title>
    <link rel="stylesheet" href="https://g.alicdn.com/de/prismplayer/2.9.19/skins/default/aliplayer-min.css" />
    <script type="text/javascript" charset="utf-8" src="https://g.alicdn.com/de/prismplayer/2.9.19/aliplayer-min.js"></script>
    <!-- 请下载之后使用 -->
    <script type="text/javascript" charset="utf-8" src="/aliplay/aliplayercomponents-1.0.8.min.js"></script>
</head>
<body>
<div id="player-con"></div>
<script>
    const saveTime = function (memoryVideo,currentTime) {
        localStorage.setItem(memoryVideo, currentTime);
    }

    const getTime = function (memoryVideo) {
        //return返回的是自定义起播时间
        return localStorage.getItem(memoryVideo)
    }
    var player = new Aliplayer({
        id: "player-con",
        source: "http://localhost/video/alone/video/play/Video6.mp4",
        width: "100%",
        height: "500px",
        autoplay: true,
        isLive: false,
        "preload": true,
        "controlBarVisibility": "always",
        components: [{
            name: 'MemoryPlayComponent',
            type: AliPlayerComponent.MemoryPlayComponent,
            args:[false,getTime,saveTime]
        }]
    }, function (player) {
        console.log("The player is created");
        //  将视频的进度存在locatStorage中，若有则直接设置进度条在哪里
        var memory_time = localStorage.getItem('memory_time:'+11);
        console.log("memory_time==" ,memory_time)
        if (memory_time){
            console.log("设置播放进度条")
            player.seek(memory_time);
        }else{
            player.seek(10);
            // //过没有，则进行数据库查询
            // var tmp = Date.parse( new Date() ).toString();
            // tmp = tmp.substr(0,10);
            // $.ajax({
            //     url:url,
            //     type:'post',
            //     async:false,
            //     data:{
            //         method:'getPlaying',
            //         code:tmp,
            //         content:{
            //             u_id:getuid,
            //             v_id:getcid
            //         }
            //     },
            //     success:function(result){
            //         console.log('进行了存储操作啊啊啊啊',result)
            //         result = JSON.parse(result)
            //         memory_time = result.data.playing;
            //         player.seek(memory_time);
            //     }
            // })
        }
    });
    player.on('timeupdate',handleReady);
    function handleReady(){
        console.log("this.c_id==",11)
        localStorage.setItem('memory_time:'+11,player.getCurrentTime());
    }
</script>
</body>
</html>
